<?php
include "../lib/DAL/HoiDongThi.php";

class HoiDongThiBLL{
    function __construct(){
    }
    
    function __destruct(){
    }

    public function SetHoiDongThiBLL($row)
    {
        $hoidongthi= new HoiDongThi();
        $hoidongthi->sethoidongthi($row['ma_hoidongthi'],$row['ma_donvihocvu'],$row['ma_donvi']);
        return $hoidongthi;   
    }
    
    public function Getma_hoidong($ma_dvhv,$ma_donvi)
    {
        $sql="SELECT ma_hoidong FROM tbl_hoidongthi WHERE ma_donvi='$ma_donvi' AND 	ma_donvihocvu='$ma_dvhv'";
        $ex=mysql_query($sql);
        if(mysql_num_rows($ex)>0){
            $kq=mysql_fetch_array($ex);
            $ma_hoidong=$kq['ma_hoidong'];   
        }else{
            $ma_hoidong=Null;
        }
            
        
        return $ma_hoidong;
    }
        
    
    public function GetlistHoidongthi(){
        $ex=mysql_query("SELECT * FROM tbl_hoidongthi");
        if($ex){
            while($row=mysql_fetch_array($ex)){
                $ds[]=$this->SetHoiDongThiBLL($row);
            }
        }
     return $ds;
    }
    
    
    public function InsertHoidongthi($dt)
    {
        $sql="  INSERT INTO tbl_hoidongthi(ma_hoidong,ma_donvihocvu,ma_donvi) 
                VALUES('".$dt->getma_hoidong()."','".$dt->getma_donvihocvu()."','".$dt->getma_donvi()."')";
        
        $kq= mysql_query($sql);
        
        return $kq;
    }
    
    
}
?>